var e = require;
var t = module;
var o = exports;
Object.defineProperty(o, "__esModule", {value: !0});
var n = e("BaseModuleUI"),
    a = e("GlobalParams"),
    i = e("AssetsManager"),
    r = e("AudioManager"),
    s = e("Game"),
    l = e("RoleSoldierInfo"),
    c = e("UIManager"),
    d = e("GetZsViewUI"),
    h = e("AD"),
    _ = e("Toast"),
    u = cc._decorator,
    p = u.ccclass,
    m = u.property,
    f = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.role_head_image = null),
                (t.role_name_label = null),
                (t.dis_count_num_label = null),
                (t.coin_node = null),
                (t.buy_coin_num = null),
                (t.zs_node = null),
                (t.buy_zs_num = null),
                (t.video_node = null),
                (t.signin_node = null),
                (t.box_node = null),
                (t.dis_count_node = null),
                (t.use_node = null),
                (t.buy_btn_node = null),
                (t.far_icon = null),
                (t.near_icon = null),
                (t.role_index = 0),
                (t.role_info = null),
                t
            );
        }
        return (
            __extends(t, e),
            (t.prototype.showRoleItemInfo = function (e) {
                (this.role_index = e), (this.role_info = s.default.shop_role_info[this.role_index]);
                var t = l.default.Role_info[this.role_info.id];
                (this.role_head_image.spriteFrame = i.default.getInstance().getHeroHeadFrame(t.C_ID)),
                    (this.role_name_label.string = t.C_Name),
                    (this.far_icon.active = 1 == t.C_type),
                    (this.near_icon.active = 0 == t.C_type),
                    (this.use_node.active =
                        -1 != a.GlobalParams.playerSkinInfo.value.have.hero.indexOf(this.role_info.id)),
                    (this.dis_count_num_label.string = 10 * this.role_info.discount + "折"),
                    (this.dis_count_num_label.node.parent.active =
                        1 != this.role_info.discount && !this.use_node.active),
                    (this.coin_node.active = 0 == this.role_info.type && !this.use_node.active),
                    (this.zs_node.active = 1 == this.role_info.type && !this.use_node.active),
                    (this.signin_node.active = 2 == this.role_info.type && !this.use_node.active),
                    (this.box_node.active = 3 == this.role_info.type && !this.use_node.active),
                    (this.video_node.active = 4 == this.role_info.type && !this.use_node.active),
                    (this.buy_coin_num.string = this.buy_zs_num.string =
                        "" + this.role_info.num * this.role_info.discount),
                    (this.dis_count_node.active = 1 != this.role_info.discount && !this.use_node.active),
                    (this.dis_count_node.getComponent(cc.Label).string = "" + this.role_info.num),
                    this.use_node.active ? (this.node.zIndex = 5) : (this.node.zIndex = this.role_info.type),
                    (this.buy_btn_node.getComponent(cc.Button).interactable = !this.use_node.active),
                    this.buy_btn_node.on("click", this.buyRoleInfo, this);
            }),
            (t.prototype.showItemType = function (e) {
                this.node.active =
                    "shop_all_btn" == e ||
                    ("shop_near_btn" == e && this.near_icon.active) ||
                    ("shop_far_btn" == e && this.far_icon.active);
            }),
            (t.prototype.buyRoleInfo = function () {
                var e = this;
                r.default.ButtonSound();
                var t = function () {
                        var t = a.GlobalParams.playerSkinInfo.value;
                        (t.use[0] = e.role_info.id),
                            t.have.hero.push(e.role_info.id),
                            (a.GlobalParams.playerSkinInfo.value = t),
                            e.showRoleItemInfo(e.role_index),
                            cc.find("UIManager").getComponent(c.default).showPopup("ObtainHeroTipView");
                    },
                    o = a.GlobalParams.PlayerInfo.value;
                if (this.coin_node.active) {
                    var n = this.role_info.num * this.role_info.discount;
                    o.coin >= n
                        ? (cc.find("UIManager").getComponent(c.default).consumeCoinAndZs(0, n), t())
                        : _.default.showNewToast("金币不足");
                } else if (this.zs_node.active) {
                    var i = this.role_info.num * this.role_info.discount;
                    o.zs >= i
                        ? (cc.find("UIManager").getComponent(c.default).consumeCoinAndZs(1, i), t())
                        : cc
                              .find("UIManager")
                              .getComponent(c.default)
                              .showPopup("GetZsViewUI", function (e) {
                                  e.getComponent(d.default).showPopupInfoView(0);
                              });
                } else
                    this.video_node.active
                        ? h.default.getInstance().showVideo(function (e) {
                              r.default.playGameBGM(), e == h.ResultEnum.Success && t();
                          })
                        : this.signin_node.active
                        ? cc.find("UIManager").getComponent(c.default).showPopup("SigninViewUI")
                        : this.box_node.active &&
                          cc.find("UIManager").getComponent(c.default).showPopup("LuckyBoxViewUI");
            }),
            __decorate([m(cc.Sprite)], t.prototype, "role_head_image", void 0),
            __decorate([m(cc.Label)], t.prototype, "role_name_label", void 0),
            __decorate([m(cc.Label)], t.prototype, "dis_count_num_label", void 0),
            __decorate([m(cc.Node)], t.prototype, "coin_node", void 0),
            __decorate([m(cc.Label)], t.prototype, "buy_coin_num", void 0),
            __decorate([m(cc.Node)], t.prototype, "zs_node", void 0),
            __decorate([m(cc.Label)], t.prototype, "buy_zs_num", void 0),
            __decorate([m(cc.Node)], t.prototype, "video_node", void 0),
            __decorate([m(cc.Node)], t.prototype, "signin_node", void 0),
            __decorate([m(cc.Node)], t.prototype, "box_node", void 0),
            __decorate([m(cc.Node)], t.prototype, "dis_count_node", void 0),
            __decorate([m(cc.Node)], t.prototype, "use_node", void 0),
            __decorate([m(cc.Node)], t.prototype, "buy_btn_node", void 0),
            __decorate([m(cc.Node)], t.prototype, "far_icon", void 0),
            __decorate([m(cc.Node)], t.prototype, "near_icon", void 0),
            __decorate([p], t)
        );
    })(n.default);
o.default = f;
